package com.example.schoolguider.controller;

import com.example.schoolguider.common.Result;
import com.example.schoolguider.common.ResultStatus;
import com.example.schoolguider.model.Point;
import com.example.schoolguider.service.PointService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @author wjc
 * @date 2024/6/30 8:47
 */
@RestController
@RequestMapping("/point")
public class PointController {
    @Autowired
    PointService pointService;

    @GetMapping("/ua/listPointsByAreaId")
    public Result listPointsByAreaId(Long areaId) {
        return Result.of(ResultStatus.SUCCESS, pointService.listPointsByAreaId(areaId));
    }
    @GetMapping("/ua/getPointById")
    public Result getPointById(Long id) {
        return Result.of(ResultStatus.SUCCESS, pointService.getPointById(id));
    }

    @PostMapping("/addPoint")
    public Result addPoint(@RequestBody Point point) {
        return Result.of(ResultStatus.SUCCESS, pointService.addPoint(point));
    } 

    @PostMapping("/updatePoint")
    public Result updatePoint(@RequestBody Point point) {
        return Result.of(ResultStatus.SUCCESS, pointService.updatePoint(point));
    }
}
